package com.example.springcloud.alibaba.controller;

import com.example.springcloud.alibaba.service.StorageService;
import com.example.springcloud.entities.CommonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class StorageController {
    @Resource
    private StorageService storageService;
    @GetMapping(value = "/storage/change")
    public CommonResult changeStorage(long productId, long used)  throws Exception {
        if(productId == 2){
            throw new Exception("模拟异常");
        }
        storageService.updateUseNum(productId,used);
        return new CommonResult(200,"库存扣减成功");
    }
}